<?php


//WP Cart Customer Management Menu
function wp_dk_estore_customer_management_menu_tpl()
{
    
	echo '<div class="wrap">
    <h2>'.__('Manage Customers Menu', 'wp_eStore').'</h2>';
    echo '<div id="poststuff"><div id="post-body">';
    if(isset($_REQUEST['eStore_export_customer_data_to_csv']))
    {    	
    	$file_url = eStore_expport_customers_data_to_csv();
    	$export_message = 'Data exported to <a href="'.$file_url.'" target="_blank">Customer List File</a>';
    	echo '<div id="message" class="updated fade"><p>';
    	echo $export_message;
    	echo '</p></div>';   	
    }
    ?>
    
	<div class="postbox">
	<h3><label for="title">Customer Search</label></h3>
	<div class="inside">
	<br /><strong>Search for a customer by entering the First Name, Last Name, Transaction ID or Email Address</strong> (Full or Partial)
	<br /><br />
	<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
    <input type="hidden" name="customer_search" id="customer_search" value="true" />
    <input name="eStore_customer_search" type="text" size="40" value=""/>
    <div class="submit">
        <input type="submit" name="customer_search" value="<?php _e('Search'); ?> &raquo;" />
    </div>   
    </form>
    </div></div>

	<div class="postbox">
	<h3><label for="title">Manage Customers Options</label></h3>
	<div class="inside">

    <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
    <input type="hidden" name="display_customer_list" id="display_customer_list" value="true" />

    <table width="100%" border="0" cellspacing="0" cellpadding="6">
    <tr valign="top"><td width="25%" align="left">
    <strong>1)</strong> Display Customer List for Product ID:
    </td><td align="left">
    <input name="wp_eStore_product_id" type="text" size="10" value="<?php echo $eStore_product_id; ?>" />
    <input type="submit" name="display_customer_list" value="<?php _e('Display List'); ?> &raquo;" />
    <br /><i>Enter the product id of the product that you want to display the customer list for and hit Display List.</i><br />
    </td></tr>
    </table>
    </form>

    <br />
    <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
    <input type="hidden" name="display_customer_email_list" id="display_customer_email_list" value="true" />

    <table width="100%" border="0" cellspacing="0" cellpadding="6">
    <tr valign="top"><td width="25%" align="left">
    <strong>2)</strong> Display Email List of Customers for Product ID:
    </td><td align="left">
    <input name="wp_eStore_product_id1" type="text" size="10" value="<?php echo $eStore_product_id1; ?>" />
    <input type="submit" name="display_customer_email_list" value="<?php _e('Display Email List'); ?> &raquo;" />
    <br /><i>Use this to display a list of emails (comma separated) of the customers for this product for bulk emailing purpuse.</i><br />
    </td></tr>
    </table>
    </form>

    <br />
    <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
    <input type="hidden" name="display_all_customer_email_list" id="display_all_customer_email_list" value="true" />

    <table width="100%" border="0" cellspacing="0" cellpadding="6">
    <tr valign="top"><td width="25%" align="left">
    <strong>3)</strong> Display Email List of All Customers:
    </td><td align="left">
    <input type="submit" name="display_all_customer_email_list" value="<?php _e('Display All Customers Email List'); ?> &raquo;" />
    <br /><i>Use this to display a list of emails (comma separated) of all the customers for bulk emailing purpuse.</i><br />
    </td></tr>
    </table>
    </form>
    </div></div>
    <?php
	if (isset($_POST['limit_update']))
	{
		update_option('eStore_manage_customers_limit', (string)$_POST["eStore_manage_customers_limit"]);
	}
    $limit = get_option('eStore_manage_customers_limit');
    if(empty($limit))
    {
        update_option('eStore_manage_customers_limit', 50);
        $limit = 50;
    }
	
	//hard code limit 
	$limit = 1000;

    global $wpdb;
   	$customer_table_name = $wpdb->prefix . "wp_eStore_customer_tbl";
       	
    $displaying_specific_list = false;
	if (isset($_POST['customer_search']))
	{
		$search_term = (string)trim($_POST["eStore_customer_search"]);
		update_option('eStore_customer_search', (string)$_POST["eStore_customer_search"]);

       $ret_customer_db = $wpdb->get_results("SELECT * FROM $customer_table_name WHERE first_name like '%".$search_term."%' OR last_name like '%".$search_term."%' OR txn_id like '%".$search_term."%' OR email_address like '%".$search_term."%'", OBJECT);
        echo dk_display_customer_list($ret_customer_db);
        $displaying_specific_list = true;
		//eStore_display_searched_products($search_term);
	}
    if ($_POST['display_customer_list'])
    {
    	$selected_product_id = (string)$_POST["wp_eStore_product_id"];
    	//$customer_table_name = WP_ESTORE_CUSTOMER_TABLE_NAME;
    	$ret_customer_db = $wpdb->get_results("SELECT * FROM $customer_table_name WHERE purchased_product_id = '$selected_product_id'", OBJECT);
        echo dk_display_customer_list($ret_customer_db);
        $displaying_specific_list = true;
    }
    if ($_POST['display_customer_email_list'])
    {
    	$selected_product_id = (string)$_POST["wp_eStore_product_id1"];
    	//$customer_table_name = WP_ESTORE_CUSTOMER_TABLE_NAME;
    	$ret_customer_db = $wpdb->get_results("SELECT * FROM $customer_table_name WHERE purchased_product_id = '$selected_product_id'", OBJECT);
        echo display_customer_email_list($ret_customer_db);
        $displaying_specific_list = true;
    }
    if ($_POST['display_all_customer_email_list'])
    {
    	$wp_eStore_customer_db = $wpdb->get_results("SELECT * FROM $customer_table_name ORDER BY id DESC", OBJECT);
        echo display_customer_email_list($wp_eStore_customer_db);
        $displaying_specific_list = true;
    }    

    if (!$displaying_specific_list)
    {
	
        echo dk_eStore_display_customer_list_limit($limit);
        ?>
		
        <?php
    }
	// Add Customer Button
	echo '<br /><br /><a href="admin.php?page=dk_eStore_customer_addedit" class="button rbutton">'.__('Add New', 'wp_eStore').'</a>';
	// echo ' <a href="admin.php?page=wp_eStore_admin" class="button rbutton">'.__('Admin Functions', 'wp_eStore').'</a>';
?>
<?php 
	
	echo '</div></div>';
    echo '</div>';
}


function wp_dk_estore_add_customer_menu_tpl()
{
	echo '<div class="wrap">';
	echo "<h2>Add/Edit Customers</h2>";
	echo '<div id="poststuff"><div id="post-body">';

	global $wpdb;
	$customer_table_name = $wpdb->prefix . "wp_eStore_customer_tbl";

	//If Customer is being edited, grab current customer info
	if ($_GET['editcustomer']!='')
	{
		$theid = $_GET['editcustomer'];
		$editingcustomer = $wpdb->get_row("SELECT * FROM $customer_table_name WHERE id = '$theid'", OBJECT);
	}

	if ($_POST['Submit'])
	{
		$post_editedcustomer = $wpdb->escape($_POST['editedcustomer']);
		$post_firstname = $wpdb->escape($_POST['firstname']);
		$post_lastname = $wpdb->escape($_POST['lastname']);
		$post_emailaddress = $wpdb->escape($_POST['emailaddress']);
		$post_purchasedproductid = $wpdb->escape($_POST['purchasedproductid']);
		$post_txn_id = $wpdb->escape($_POST['txn_id']);
		$post_date = $wpdb->escape($_POST['date']);
		if(empty($post_date)){
			$post_date = (date ("Y-m-d"));
		}
		$post_sale_amt = $wpdb->escape($_POST['sale_amount']);
		$post_coupon_code_used = $wpdb->escape($_POST['coupon_code_used']);
		$post_member_username = $wpdb->escape($_POST['member_username']);
			
		$post_product_name = $wpdb->escape(stripslashes($_POST['product_name']));
		$tmpaddress = htmlentities(stripslashes($_POST['address']) , ENT_COMPAT);
		$post_address = $wpdb->escape($tmpaddress);
		$post_phone = $wpdb->escape($_POST['phone']);
		$post_qty_purchased = $wpdb->escape($_POST['purchase_qty']);	
		$post_subsc_id = "";	
		$post_ipaddress = $wpdb->escape($_POST['ipaddress']);		
		$post_status = $wpdb->escape($_POST['status']);			
		
		if ($post_editedcustomer=='')
		{
			$updatedb = "INSERT INTO $customer_table_name (first_name, last_name, email_address, purchased_product_id,txn_id,date,sale_amount,coupon_code_used,member_username,product_name,address,phone,subscr_id,purchase_qty,ipaddress,status) VALUES ('$post_firstname', '$post_lastname','$post_emailaddress','$post_purchasedproductid','$post_txn_id','$post_date','$post_sale_amt','$post_coupon_code_used','$post_member_username','$post_product_name','$post_address','$post_phone','$post_subsc_id','$post_qty_purchased','$post_ipaddress','$post_status')";
			$results = $wpdb->query($updatedb);
			echo '<div id="message" class="updated fade"><p>Customer &quot;'.$post_firstname.'&quot; created.</p></div>';
		}
		else
		{
			$updatedb = "UPDATE $customer_table_name SET first_name = '$post_firstname', last_name = '$post_lastname', email_address = '$post_emailaddress', purchased_product_id = '$post_purchasedproductid', txn_id='$post_txn_id',date='$post_date',sale_amount='$post_sale_amt',coupon_code_used='$post_coupon_code_used',member_username='$post_member_username',product_name='$post_product_name',address='$post_address',phone='$post_phone',purchase_qty='$post_qty_purchased',ipaddress='$post_ipaddress',status='$post_status' WHERE id='$post_editedcustomer'";
			$results = $wpdb->query($updatedb);
			//Get the updated customer again
    		$_GET['editcustomer'] = $post_editedcustomer;
    		$editingcustomer = $wpdb->get_row("SELECT * FROM $customer_table_name WHERE id = '$post_editedcustomer'", OBJECT);			
			echo '<div id="message" class="updated fade"><p>'.__('Customer', 'wp_eStore').' &quot;'.$post_firstname.'&quot; '.__('updated.', 'wp_eStore').'</p></div>';
		}
	}
	// Copy Product Details
	if ($_POST['copy_customer'])
	{
        $post_orig_customer_id = $wpdb->escape($_POST['orig_customer_id']);
	    $editingcustomer = $wpdb->get_row("SELECT * FROM $customer_table_name WHERE id = '$post_orig_customer_id'", OBJECT);
	    echo '<div id="message" class="updated fade"><p>'.__('Details from Customer ID', 'wp_eStore').' &quot;'.$post_orig_customer_id.'&quot; '.__('has been copied. Make your changes and save the new details.', 'wp_eStore').'</p></div>';
	}	
	// Delete Customer
	if ($_POST['deletecustomer'])
	{
		$post_editedcustomer = $wpdb->escape($_POST['editedcustomer']);
		echo '<div id="message" class="updated fade"><p>'.__('Do you really want to delete this Customer? This action cannot be undone.', 'wp_eStore').' <a href="admin.php?page=dk_eStore_customer_addedit&deletecustomer='.$post_editedcustomer.'">'.__('Yes', 'wp_eStore').'</a> &nbsp; <a href="admin.php?page=dk_eStore_customer_addedit&editcustomer='.$post_editedcustomer.'">'.__('No!', 'wp_eStore').'</a></p></div>';
	}
	if ($_GET['deletecustomer']!='')
	{
		$thecustomer=$_GET['deletecustomer'];
		$updatedb = "DELETE FROM $customer_table_name WHERE id='$thecustomer'";
		$results = $wpdb->query($updatedb);
		echo '<div id="message" class="updated fade"><p>'.__('Customer deleted.', 'wp_eStore').'</p></div>';
	}
?>
	<div class="postbox">
	<h3><label for="title">Customer Details</label></h3>
	<div class="inside">
<form method="post" action="admin.php?page=dk_eStore_customer_addedit">
<table class="form-table">

<?php if ($_GET['editcustomer']!='') { echo '<input name="editedcustomer" type="hidden" value="'.$_GET['editcustomer'].'" />'; } ?>

<tr valign="top">
<th scope="row"><?php _e('First Name', 'wp_eStore'); ?></th>
<td><input name="firstname" type="text" id="firstname" value="<?php echo $editingcustomer->first_name; ?>" size="40" /><br/><?php _e('First Name of the customer', 'wp_eStore'); ?></td>
</tr>

<tr valign="top">
<th scope="row"><?php _e('Last Name', 'wp_eStore'); ?></th>
<td><input name="lastname" type="text" id="lastname" value="<?php echo $editingcustomer->last_name; ?>" size="40" /><br/><?php _e('Last Name of the customer', 'wp_eStore'); ?></td>
</tr>

<tr valign="top">
<th scope="row"><?php _e('Email Address', 'wp_eStore'); ?></th>
<td><input name="emailaddress" type="text" id="emailaddress" value="<?php echo $editingcustomer->email_address; ?>" size="60" /><br/><?php _e('The Email Address of the customer', 'wp_eStore'); ?></td>
</tr>

<tr valign="top">
<th scope="row"><?php _e('Address', 'wp_eStore'); ?></th>
<td><textarea name="address" cols="40" rows="3"><?php echo $editingcustomer->address; ?></textarea>
<br/><?php _e('The address of the customer', 'wp_eStore'); ?></td>
</tr>

<tr valign="top">
<th scope="row"><?php _e('Phone', 'wp_eStore'); ?></th>
<td><input name="phone" type="text" id="phone" value="<?php echo $editingcustomer->phone; ?>" size="20" /><br/><?php _e('The phone number of the customer', 'wp_eStore'); ?></td>
</tr>

<tr valign="top">
<th scope="row"><?php _e("Purchased Product's ID", 'wp_eStore'); ?></th>
<td><input name="purchasedproductid" type="text" id="purchasedproductid" value="<?php echo $editingcustomer->purchased_product_id; ?>" size="5" /><br/><?php _e('The product ID of the purchased product', 'wp_eStore'); ?></td>
</tr>

<tr valign="top">
<th scope="row"><?php _e('Product Name', 'wp_eStore'); ?></th>
<td><input name="product_name" type="text" id="product_name" value="<?php echo $editingcustomer->product_name; ?>" size="60" /><br/><?php _e('The name of the purchased product', 'wp_eStore'); ?></td>
</tr>


<tr valign="top">
<th scope="row"><?php _e('Date', 'wp_eStore'); ?></th>
<td><input name="date" type="text" id="date" value="<?php echo $editingcustomer->date; ?>" size="20" /><br/><?php _e('The purchase date (yyyy-mm-dd)', 'wp_eStore'); ?></td>
</tr>

<tr valign="top">
<th scope="row"><?php _e('Price Paid', 'wp_eStore'); ?></th>
<td><input name="sale_amount" type="text" id="sale_amount" value="<?php echo $editingcustomer->sale_amount; ?>" size="10" /><br/><?php _e('Purchase amount', 'wp_eStore'); ?></td>
</tr>

<tr valign="top">
<th scope="row"><?php _e('Quantity Purchased', 'wp_eStore'); ?></th>
<td><input name="purchase_qty" type="text" id="purchase_qty" value="<?php echo $editingcustomer->purchase_qty; ?>" size="5" /><br/><?php _e('Item quantity', 'wp_eStore'); ?></td>
</tr>


<tr valign="top">
<th scope="row"><?php _e('Payment Status', 'wp_eStore'); ?></th>
<td><input name="status" type="text" id="status" value="<?php echo $editingcustomer->status; ?>" size="15" /><br/><?php _e('Payment status of this transaction. For manual payment this is set to "Unpaid" by default. You can set it to "Paid" after you actually receive the money from the buyer.', 'wp_eStore'); ?></td>
</tr>

</table>
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Save Customer', 'wp_eStore'); ?>" /> &nbsp; <?php if ($_GET['editcustomer']!='') { ?><input type="submit" name="deletecustomer" value="<?php _e('Delete Customer', 'wp_eStore'); ?>" /><?php } ?></p>
</form>
</div></div>

<div class="postbox">
<h3><label for="title">Copy Customer Details from an Existing Customer</label></h3>
<div class="inside">

To copy the details from an existing Customer simply enter the ID of the Customer whose details you wish to copy and hit the "Copy Customer Details" button
<br /><br />
<form method="post" action="">
Customer ID:
<input name="orig_customer_id" type="text" id="orig_customer_id" value="" size="5" />
<input type="submit" name="copy_customer" value="<?php _e('Copy Customer Details', 'wp_eStore'); ?>" />
</form>
</div>
</div>
<?php

	echo '<br /><a href="admin.php?page=dk_estore_customer_management" class="button rbutton">'.__('Manage Customers', 'wp_eStore').'</a>';
	echo '</div></div>';
	echo '</div>';
}


function dk_eStore_display_customer_list_limit($limit)
{

	$output .= '
	<table class="widefat">
	<thead><tr>
	<th scope="col">'.__('Customer ID', 'wp_eStore').'</th>
	<th scope="col">'.__('First Name', 'wp_eStore').'</th>
	<th scope="col">'.__('Last Name', 'wp_eStore').'</th>
	<th scope="col">'.__('Email Address', 'wp_eStore').'</th>
	<th scope="col">'.__('Purchased Product\'s ID', 'wp_eStore').'</th>
	<th scope="col">'.__('Transaction ID', 'wp_eStore').'</th>
    <th scope="col">'.__('Date', 'wp_eStore').'</th>
    <th scope="col">'.__('Price Paid', 'wp_eStore').'</th>
    <th scope="col">'.__('Coupon Used', 'wp_eStore').'</th>
    <th scope="col">'.__('Status', 'wp_eStore').'</th>
	<th scope="col"></th>
	</tr></thead>
	<tbody>';

    if (isset($_GET['product_page']))
    {
        $page = $_GET['product_page'];
    }
    else
    {
        $page = 1;
    }
    $start = ($page - 1) * $limit;

	global $wpdb;
	//$products_table_name = $wpdb->prefix . "wp_eStore_tbl";
	$customer_table_name = $wpdb->prefix . "wp_eStore_customer_tbl";

	$wp_eStore_db = $wpdb->get_results("SELECT * FROM $customer_table_name ORDER BY id DESC LIMIT $start, $limit", OBJECT);
    //get total rows
    $totalrows = $wpdb->get_var("SELECT COUNT(*) FROM $customer_table_name;");

	if ($wp_eStore_db)
	{
		foreach ($wp_eStore_db as $wp_eStore_db)
		{
			//check if record is belong to current user
			$mk_current_user_id = get_option('dk_eshop_user_product_record'. $wp_eStore_db->purchased_product_id);
			if(dk_eshop_get_e_member_id() != $mk_current_user_id )
				continue;
		
			$output .= '<tr>';
			$output .= '<td>'.$wp_eStore_db->id.'</td>';
			$output .= '<td><strong>'.$wp_eStore_db->first_name.'</strong></td>';
			$output .= '<td><strong>'.$wp_eStore_db->last_name.'</strong></td>';
			$output .= '<td><strong>'.$wp_eStore_db->email_address.'</strong></td>';
			$output .= '<td><strong>'.$wp_eStore_db->purchased_product_id.'</strong></td>';
			$output .= '<td><strong>'.$wp_eStore_db->txn_id.'</strong></td>';
			$output .= '<td><strong>'.$wp_eStore_db->date.'</strong></td>';
			$output .= '<td><strong>'.$wp_eStore_db->sale_amount.'</strong></td>';
			if(!empty($wp_eStore_db->coupon_code_used))
			{
				$output .= '<td><strong>'.$wp_eStore_db->coupon_code_used.'</strong></td>';
			}
			else
			{
				$output .= '<td><strong>--</strong></td>';
			}
			$output .= '<td><strong>'.$wp_eStore_db->status.'</strong></td>';	
			$output .= '<td><a href="admin.php?page=dk_eStore_customer_addedit&editcustomer='.$wp_eStore_db->id.'">'.__('Edit / View Details', 'wp_eStore').'</a></td>';
			$output .= '</tr>';
		}
	}
	else
	{
		$output .= '<tr> <td colspan="8">'.__('No Customers found.', 'wp_eStore').'</td> </tr>';
	}

	$output .= '</tbody>
	</table>';
    
    //Number of pages setup
    if($totalrows <= $limit){//No pagination needed
    	return $output;
    }
	$pages = ceil($totalrows / $limit);
	$output .= "<br /><strong>Pages</strong>&nbsp;&nbsp;";
	if($page==1){
		$output .= "<a href='admin.php?page=wp_estore_customer_management&product_page=".$page."' class=\"button rbutton\">".$page."</a>&nbsp;";
		$output .= "<a href='admin.php?page=wp_estore_customer_management&product_page=".($page+1)."' class=\"button rbutton\">".($page+1)."</a>&nbsp;";
		$output .= "<a href='admin.php?page=wp_estore_customer_management&product_page=".($page+2)."' class=\"button rbutton\">".($page+2)."</a>&nbsp;";
	}
	else if($page==$pages){
		$output .= "<a href='admin.php?page=wp_estore_customer_management&product_page=".($page-2)."' class=\"button rbutton\">".($page-2)."</a>&nbsp;";
		$output .= "<a href='admin.php?page=wp_estore_customer_management&product_page=".($page-1)."' class=\"button rbutton\">".($page-1)."</a>&nbsp;";
		$output .= "<a href='admin.php?page=wp_estore_customer_management&product_page=".$page."' class=\"button rbutton\">".$page."</a>&nbsp;";			
	}
	else{
		$output .= "<a href='admin.php?page=wp_estore_customer_management&product_page=".($page-1)."' class=\"button rbutton\">".($page-1)."</a>&nbsp;";
		$output .= "<a href='admin.php?page=wp_estore_customer_management&product_page=".$page."' class=\"button rbutton\">".$page."</a>&nbsp;";
		$output .= "<a href='admin.php?page=wp_estore_customer_management&product_page=".($page+1)."' class=\"button rbutton\">".($page+1)."</a>&nbsp;";
	}
	
	//Last page
	$output .= " .......... ";
	$output .= "<a href='admin.php?page=wp_estore_customer_management&product_page=".$pages."' class=\"button rbutton\">".$pages."</a>&nbsp;";
    return $output;
}


function dk_display_customer_list($ret_customer_db)
{
	$output .= '
	<table class="widefat">
	<thead><tr>
	<th scope="col">'.__('Customer ID', 'wp_eStore').'</th>
	<th scope="col">'.__('First Name', 'wp_eStore').'</th>
	<th scope="col">'.__('Last Name', 'wp_eStore').'</th>
	<th scope="col">'.__('Email Address', 'wp_eStore').'</th>
	<th scope="col">'.__("Purchased Product's ID", 'wp_eStore').'</th>
	<th scope="col">'.__('Transaction ID', 'wp_eStore').'</th>
    <th scope="col">'.__('Date', 'wp_eStore').'</th>
    <th scope="col">'.__('Price Paid', 'wp_eStore').'</th>
    <th scope="col">'.__('Coupon Used', 'wp_eStore').'</th>
    <th scope="col">'.__('Status', 'wp_eStore').'</th>
	<th scope="col"></th>
	</tr></thead>
	<tbody>';

	if ($ret_customer_db)
	{
		foreach ($ret_customer_db as $ret_customer_db)
		{
			//check if record is belong to current user
			$mk_current_user_id = get_option('dk_eshop_user_product_record'. $wp_eStore_db->purchased_product_id);
			if(dk_eshop_get_e_member_id() != $mk_current_user_id )
				continue;
			
			
			$output .= '<tr>';
			$output .= '<td>'.$ret_customer_db->id.'</td>';
			$output .= '<td><strong>'.$ret_customer_db->first_name.'</strong></td>';
			$output .= '<td><strong>'.$ret_customer_db->last_name.'</strong></td>';
			$output .= '<td><strong>'.$ret_customer_db->email_address.'</strong></td>';
			$output .= '<td><strong>'.$ret_customer_db->purchased_product_id.'</strong></td>';
			$output .= '<td><strong>'.$ret_customer_db->txn_id.'</strong></td>';
			$output .= '<td><strong>'.$ret_customer_db->date.'</strong></td>';
			$output .= '<td><strong>'.$ret_customer_db->sale_amount.'</strong></td>';
			if(!empty($ret_customer_db->coupon_code_used))
			{
				$output .= '<td><strong>'.$ret_customer_db->coupon_code_used.'</strong></td>';
			}
			else
			{
				$output .= '<td><strong>--</strong></td>';
			}
			$output .= '<td><strong>'.$ret_customer_db->status.'</strong></td>';			
			$output .= '<td><a href="admin.php?page=dk_eStore_customer_addedit&editcustomer='.$ret_customer_db->id.'">'.__('Edit / View Details', 'wp_eStore').'</a></td>';
			$output .= '</tr>';
		}
	}
	else
	{
		$output .= '<tr> <td colspan="8">'.__('No Customers found.', 'wp_eStore').'</td> </tr>';
	}

	$output .= '</tbody>
	</table>';
	return $output;
}
?>